import axios from 'axios'

const baseURL = process.env.NODE_ENV === 'production' ? 'http://124.220.202.89/Chicken-Music/' : '/'
const ERR_OK = 0

axios.defaults.baseURL = baseURL

export function get (url, params) {
  return axios
    .get(url, {
      params
    })
    .then((res) => {
      const serveData = res.data
      if (serveData.code === ERR_OK) {
        return serveData.result
      }
    })
    .catch((err) => {
      console.log(err)
      console.log(111)
    })
}
